var t = getApp();

Page({
    data: {
        activeName: 0,
        isCoupon: !1,
        page: 1,
        finished: !1,
        orderList: []
    },
    onLoad: function(t) {
        t.status && this.setData({
            activeName: Number(t.status)
        });
        var a = t.title || "聚合CPS订单";
        wx.setNavigationBarTitle({
            title: a
        }), this.getData();
    },
    onShow: function() {},
    switchTab: function(t) {
        this.initGetData(), this.setData({
            activeName: t.detail.name
        }), this.getData();
    },
    getData: function() {
        var a = this;
        if (!this.data.finished) {
            var e = t.getNetAddresss("plugin.aggregation-cps.api.order.index");
            t._getNetWork({
                url: e,
                data: {
                    status: this.data.activeName,
                    page: this.data.page
                },
                success: function(t) {
                    if (1 !== t.data.result) return wx.showToast({
                        title: t.data.msg
                    }), !1;
                    var e = t.data.data, i = !1, s = [];
                    (a.data.page >= e.last_page || !e.data || e.data.length < e.per_page) && (i = !0), 
                    s = a.data.page > 1 ? a.data.orderList.concat(e.data) : e.data, a.setData({
                        finished: i,
                        orderList: s,
                        page: ++a.data.page
                    });
                }
            });
        }
    },
    initGetData: function() {
        this.setData({
            page: 1,
            finished: !1
        });
    },
    onPullDownRefresh: function() {
        this.initGetData(), this.getData();
    },
    onReachBottom: function() {
        this.data.finished || this.getData();
    }
});